<!DOCTYPE html>

	<?php 
	include 'product.php';
	session_start();
	$sum = 0;
	if(!empty($_SESSION['cart'])){
		$order=$_SESSION['cart'];
		$sum=array_sum(array_column($order,"num"));
	}
	?>
	<html>
	<head>
		<meta charset="utf-8">
		<link rel="stylesheet" type="text/css" href="css/style,css" />
		<title>PHP购物</title>
	</head>
	<body>
		<div>
			<h1>商品列表</h1>
			<table>
				<tr>
					<th>商品名</th>
					<th>售价</th>
					<th>购物车</th>
				</tr>
				<?php foreach ($product as $key => $value):?>
               <tr>
				   <td><?php echo $value['name'];?></td>
				   <td><?php echo $value['price'];?></td>
				   <td><a class="btn" href="addCart.php?upd=add&id=<?php echo$value['id'];?>&name=<?php echo $value['name'];?>&price=<?php echo $value['price'];?>">+</a></td>
			   </tr>
				<?php endforeach;?> <!--<?php (7);?>-->
			</table>
			<div>
				<a href="addCart.php?upd=cart">我的购物车</a>
				<span><?php echo $sum;?></span>
			</div>
		</div>
		
	</body>
</html>
